//Task.hpp
//将多个客户端的请求当做线程池的一个任务
#pragma once
#include <iostream>
#include <unistd.h>
#include <string>
#include <functional>
using namespace std;

using cb_t=function<void(uint16_t,string,int)>;//和下面的typedef是一样的功能
//typedef void(*cb_t)(uint16_t,string);

class Task
{
public:
    Task()
    {}

    Task(uint16_t clientport,const string& clientip,cb_t w,int sock)
        :_clientport(clientport),
        _clientip(clientip),
        _way(w),
        _sock(sock)
    {}

    void operator()()
    {
        _way(_clientport,_clientip,_sock);
    }
    
private:
    uint16_t _clientport;
    string _clientip;
    cb_t _way;
    int _sock;
};